package com.itboye.sunsunhome.www.aq;

import java.io.FileNotFoundException;
import java.util.ArrayList;

import com.itboye.base.BaseActivity;
import com.itboye.sunsunhome.util.CustomDialog;
import com.itboye.sunsunhome.util.DownPicUtils;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;


public class AqWebActivity extends BaseActivity {

	WebView webView;
	Context context;

	TextView title;

	String imgUrl;
	String id;
	ImageView back;
	RelativeLayout backrela;
	private String url;
	 WebView.HitTestResult hitTestResult;
	private ArrayAdapter<String> adapter;
	private CustomDialog mCustomDialog;

	@Override
	@SuppressLint("InlinedApi")
	protected void onCreate(Bundle arg0) {
		// TODO Auto-generated method stub
		super.onCreate(arg0);
		setContentView(R.layout.add_device_new);
		webView = (WebView) findViewById(R.id.webview);
		webView.setHorizontalScrollBarEnabled(false);// 水平不显示
		webView.setVerticalScrollBarEnabled(false); // 垂直不显示
		url = getIntent().getStringExtra("url");
		System.out.println("LLLLLLLLLLLLLLLLL"+url);
		context = this;
		back=(ImageView) findViewById(R.id.back);
		loadWeb();
		initData();
		
		back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
	}

	public void loadWeb(){
//        url = "https://www.baidu.com/";
        //此方法可以在webview中打开链接而不会跳转到外部浏览器
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl(url);
    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {    
        //重写onKeyDown，当浏览网页，WebView可以后退时执行后退操作。
        if(keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack()){
            webView.goBack();
            return true;
        } 
        return super.onKeyDown(keyCode, event);
    }
    @SuppressLint("NewApi") private void initData() {
		WebSettings settings = webView.getSettings();
		settings.setJavaScriptEnabled(true);
		settings.setUseWideViewPort(true);// 设置此属性，可任意比例缩放
		settings.setLoadWithOverviewMode(true);
		// 使页面支持缩放
		settings.setBuiltInZoomControls(true);
		settings.setSupportZoom(true);
		// 支持自动加载图片
		settings.setLoadsImagesAutomatically(true);
		settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);// 排版适应屏幕
		// 缩放按钮
		settings.setDisplayZoomControls(false);

	}
}
